﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Acms.AcmsControls;

public partial class Templates_BrochureItem_Default : Acms.AcmsControls.TemplatePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DataBind();
        }
        var post = AcmsContext.CurrentPost.Name;
        var flashUrl = AcmsContext.SiteRoot;
        //FlBrochure.FlashFileUrl = "";
        FlBrochure.FlashFileUrl = GetBrochurePath();
        FlBrochure.Variables.Add("FullScreen", "true");
        //flashFooter.Variables.Add("SiteRoot", string.Concat("http://", AcmsContext.SiteRoot));
    }

    protected string GetBrochurePath()
    {
        return "http://" + HttpContext.Current.Request.Url.Host + "/Brochures/" + AcmsContext.CurrentPost.Name + "/main.swf";
    }

    protected string GetImgSrc()
    {
        var heroImage = AcmsContext.CurrentPost.FindPostControl("HeroImage");
        var host = HttpContext.Current.Request.Url.Host;
        if (heroImage != null)
        {
            var heroImageProperties = heroImage.GetProperties<Acms.AcmsControls.ImageContentControlProperties>();
            if (heroImageProperties != null)
            {
                return "http://" + host + ResolveUrl(Acms.AcmsControls.RenderFile.GetUrl(heroImageProperties.ResourceId, null, null, this));
            }
        }
        return null;
    }
}
